package com.central.rearService.controller

import com.central.common.annotation.LoginUser
import com.central.common.enum.LikeTypeEnum
import com.central.common.model.CommonResult
import com.central.common.model.RealDataResult
import com.central.common.model.SysUser
import com.central.rearService.service.LikeService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*
import springfox.documentation.annotations.ApiIgnore

/**
 * @author  fly
 * @date  2021/5/26 14:55
 * @version 1.0
 */
@Api(tags = ["(小程序) 点赞模块"])
@RestController
@RequestMapping("like")
open class LikeController {

    @Autowired
    private lateinit var likeService: LikeService


    @ApiOperation("处理点赞")
    @PostMapping("resolveLike")
    fun resolveLike(likeId: Long, @ApiIgnore @LoginUser sysUser: SysUser, likeType: Int): CommonResult<Boolean> = likeService.resolveLike(likeId, sysUser, likeType)

    @ApiOperation("(rpc) 获取点赞的个数")
    @GetMapping("getLikeNum/{likeId}")
    fun getLikeNum(@PathVariable likeId: Long, likeTypeEnum: LikeTypeEnum): RealDataResult = likeService.getLikeNum(likeId, likeTypeEnum)

    @ApiOperation("(rpc) 是否点赞")
    @PostMapping("/booleanLike")
    fun booleanLike(likeId: Long, userId: Long, likeTypeEnum: LikeTypeEnum): RealDataResult = likeService.booleanLike(likeId, userId, likeTypeEnum)
}
